# Replication Archive for: 
# Cho, Joan and Dominika Kruszewska
# Escaping Collective Responsibility in Fluid Party Systems: Evidence from South Korea.
# Replication Code

#===========================================================================================================================================

rm(list=ls())
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ipak <- function(pkg){  new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if(length(new.pkg)) install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}

packages <- c("memisc", "car", "stm", "tm", "wordcloud", "MASS", "apsrtable", "stargazer") 
ipak(packages)

#uncomment to set working directory
#setwd("~/Dropbox/ChoKruszewska/data")

#============================================================================================================================================================================================#
#===============================================================Load survey===============================================================================================#
#============================================================================================================================================================================================#
load("ChoKruszewska_replication_data.RData")
dim(survey)
head(survey)
#============================================================================================================================================================================================#
#===============================================================Prepping the survey for analysis===============================================================================================#
#============================================================================================================================================================================================#

##renaming and creating the variables
survey$vote <- as.numeric(paste(survey$vote_1, survey$vote_1.1, survey$vote_1.2, survey$vote_1.3))
survey$support <- ifelse(survey$vote>4, 1, 0)

survey$corrupt_scale <- as.numeric(paste(survey$corrupt_1, survey$corrupt_1.1, survey$corrupt_1.2, survey$corrupt_1.3))
survey$corrupt <- ifelse(survey$corrupt_scale>4, 1, 0)

#============================================================================================================================================================================================#
#===============================================================Testing hypotheses===============================================================================================#
#============================================================================================================================================================================================#

#===============================================================Vote choice===============================================================================================#

##difference in means for vote choice (7 point scale turned into a binary outcome)

diff.in.means1 <- t.test(survey[survey$protest_strategy==1,]$support, survey[survey$loyalty_strategy==1,]$support)
effect1 <- diff.in.means1$estimate[1]-diff.in.means1$estimate[2]

diff.in.means2 <- t.test(survey[survey$criticism_strategy==1,]$support, survey[survey$loyalty_strategy==1,]$support)
effect2 <- diff.in.means2$estimate[1]-diff.in.means2$estimate[2]

diff.in.means3 <- t.test(survey[survey$exit_strategy==1,]$support, survey[survey$loyalty_strategy==1,]$support)
effect3 <- diff.in.means3$estimate[1]-diff.in.means3$estimate[2]

###Figure 1: vote effects for all three strategies / binary DV

par(mfrow=c(3,1))
plot(effect1,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(diff.in.means1$conf.int[1],3,diff.in.means1$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Protest) on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(effect2,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(diff.in.means2$conf.int[1],3,diff.in.means2$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Criticism) on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"),cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(effect3,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(diff.in.means3$conf.int[1],3,diff.in.means3$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Exit on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

#===============================================================Corruption===============================================================================================#

##difference in means for corruption (7 point scale turned into a binary outcome)

corruption_protest <- t.test(survey[survey$protest_strategy==1,]$corrupt, survey[survey$loyalty_strategy==1,]$corrupt)
corruption_effect_protest <- corruption_protest$estimate[1]-corruption_protest$estimate[2]

corruption_voice <- t.test(survey[survey$criticism_strategy==1,]$corrupt, survey[survey$loyalty_strategy==1,]$corrupt)
corruption_effect_voice <- corruption_voice$estimate[1]-corruption_voice$estimate[2]

corruption_exit <- t.test(survey[survey$exit_strategy==1,]$corrupt, survey[survey$loyalty_strategy==1,]$corrupt)
corruption_effect_exit <- corruption_exit$estimate[1]-corruption_exit$estimate[2]

###Figure 2: corruption effects for all three strategies / binary DV

par(mfrow=c(3,1))
plot(corruption_effect_protest,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(corruption_protest$conf.int[1],3,corruption_protest$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Protest) on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(corruption_effect_voice,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(corruption_voice$conf.int[1],3,corruption_voice$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Criticism) on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(corruption_effect_exit,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(corruption_exit$conf.int[1],3,corruption_exit$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Exit on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)


#============================================================================================================================================================================================#
#===============================================================Strategies relative to each other===============================================================================================#
#============================================================================================================================================================================================#

#===============================================================Vote choice (7 point scale turned into a binary outcome)========================================================================#


protest.criticism <- t.test(survey[survey$protest_strategy==1,]$support, survey[survey$criticism_strategy==1,]$support)
protest.criticism.effect <- protest.criticism$estimate[1]-protest.criticism$estimate[2]

protest.exit <- t.test(survey[survey$protest_strategy==1,]$support, survey[survey$exit_strategy==1,]$support)
protest.exit.effect <- protest.exit$estimate[1]-protest.exit$estimate[2]

exit.criticism <- t.test(survey[survey$criticism_strategy==1,]$support, survey[survey$exit_strategy==1,]$support)
exit.criticism.effect <- exit.criticism$estimate[1]-exit.criticism$estimate[2]

###Figure 3: vote effects for all three strategies / binary support level

par(mfrow=c(3,1))
plot(protest.criticism.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(protest.criticism$conf.int[1],3,protest.criticism$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Criticism on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(protest.exit.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(protest.exit$conf.int[1],3,protest.exit$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Exit on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(exit.criticism.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(exit.criticism$conf.int[1],3,exit.criticism$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Criticism Relative to Exit on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

#===============================================================Corruption (7 point scale turned into a binary outcome)====================================================#

protest.criticism.corrupt <- t.test(survey[survey$protest_strategy==1,]$corrupt, survey[survey$criticism_strategy==1,]$corrupt)
protest.criticism.corrupt.effect <- protest.criticism.corrupt$estimate[1]-protest.criticism.corrupt$estimate[2]

protest.exit.corrupt <- t.test(survey[survey$protest_strategy==1,]$corrupt, survey[survey$exit_strategy==1,]$corrupt)
protest.exit.corrupt.effect <- protest.exit.corrupt$estimate[1]-protest.exit.corrupt$estimate[2]

exit.criticism.corrupt <- t.test(survey[survey$criticism_strategy==1,]$corrupt, survey[survey$exit_strategy==1,]$corrupt)
exit.criticism.corrupt.effect <- exit.criticism.corrupt$estimate[1]-exit.criticism.corrupt$estimate[2]

###Figure 4: corruption effects for all three strategies / binary DV

par(mfrow=c(3,1))
plot(protest.criticism.corrupt.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(protest.criticism.corrupt$conf.int[1],3,protest.criticism.corrupt$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Criticism on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(protest.exit.corrupt.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(protest.exit.corrupt$conf.int[1],3,protest.exit.corrupt$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Exit on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(exit.criticism.corrupt.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(exit.criticism.corrupt$conf.int[1],3,exit.criticism.corrupt$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Criticism Relative to Exit on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

#============================================================================================================================================================================================#
#===============================================================Appendix===============================================================================================#
#============================================================================================================================================================================================#

#===============================================================Tables 1 & 3: Summary statistics====================================================#
survey$male <- ifelse(survey$gender==1, 1, 0)
mean(survey$male)
sd(survey$male)
mean(as.numeric(as.character(survey$age)))
mean(as.numeric(as.character(survey$education)))
sum(survey$age==1)/nrow(survey)
sum(survey$age==2)/nrow(survey)
sum(survey$age==3)/nrow(survey)
sum(survey$age==4 | survey$age==5)/nrow(survey)
sum(survey$education==1)/nrow(survey)
sum(survey$education==2)/nrow(survey)
sum(survey$education==3)/nrow(survey)
sum(survey$education==4)/nrow(survey)
survey$ideology <- as.numeric(as.character(survey$ideology_1))
mean(survey$ideology)
##create variables for supporters of all parties
survey$mp <- ifelse(survey$partisanship==2, 1, 0)
survey$sp <- ifelse(survey$partisanship==3, 1, 0)
mean(survey$mp)
mean(survey$sp)
survey$pp <-ifelse(survey$partisanship==1, 1, 0)
survey$jp <-ifelse(survey$partisanship==4, 1, 0)
survey$other <-ifelse(survey$partisanship==6, 1, 0)
#dependent variables
#binary
mean(survey$support)
mean(survey$corrupt)
#cont.
mean(survey$vote)
mean(survey$corrupt_scale)

#===============================================================Additional Analyses: By Respondents' Party==========================================================================

mp <- survey[survey$mp==1,] #451 respondents
sp <- survey[survey$sp==1,] #206 respondents

##vote 
mp_vote_protest <- t.test(mp[mp$protest_strategy==1,]$support, mp[mp$loyalty_strategy==1,]$support)
sp_vote_protest <- t.test(sp[sp$protest_strategy==1,]$support, sp[sp$loyalty_strategy==1,]$support)
mp_vote_voice <- t.test(mp[mp$criticism_strategy==1,]$support, mp[mp$loyalty_strategy==1,]$support)
sp_vote_voice <- t.test(sp[sp$criticism_strategy==1,]$support, sp[sp$loyalty_strategy==1,]$support)
mp_vote_exit <- t.test(mp[mp$exit_strategy==1,]$support, mp[mp$loyalty_strategy==1,]$support)
sp_vote_exit <- t.test(sp[sp$exit_strategy==1,]$support, sp[sp$loyalty_strategy==1,]$support)

##corruption
mp_corrupt_protest <- t.test(mp[mp$protest_strategy==1,]$corrupt, mp[mp$loyalty_strategy==1,]$corrupt)
sp_corrupt_protest <- t.test(sp[sp$protest_strategy==1,]$corrupt, sp[sp$loyalty_strategy==1,]$corrupt)
mp_corrupt_voice <- t.test(mp[mp$criticism_strategy==1,]$corrupt, mp[mp$loyalty_strategy==1,]$corrupt)
sp_corrupt_voice <- t.test(sp[sp$criticism_strategy==1,]$corrupt, sp[sp$loyalty_strategy==1,]$corrupt)
mp_corrupt_exit <- t.test(mp[mp$exit_strategy==1,]$corrupt, mp[mp$loyalty_strategy==1,]$corrupt)
sp_corrupt_exit <- t.test(sp[sp$exit_strategy==1,]$corrupt, sp[sp$loyalty_strategy==1,]$corrupt)

###Figure 2 (appendix): vote effects for all three strategies / binary support level for MP voters

par(mfrow=c(3,1))
plot(mp_vote_protest$estimate[1]-mp_vote_protest$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(mp_vote_protest$conf.int[1],3,mp_vote_protest$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Protest) on Support: MP voters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(mp_vote_voice$estimate[1]-mp_vote_voice$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(mp_vote_voice$conf.int[1],3,mp_vote_voice$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of  Voice (Criticism) on Support: MP voters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(mp_vote_exit$estimate[1]-mp_vote_exit$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(mp_vote_exit$conf.int[1],3,mp_vote_exit$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Exit on Support: MP voters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

###Figure 3 (appendix): vote effects for all three strategies / binary support level for SP voters
par(mfrow=c(3,1))
plot(sp_vote_protest$estimate[1]-sp_vote_protest$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(sp_vote_protest$conf.int[1],3,sp_vote_protest$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Protest) on Support: SP voters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(sp_vote_voice$estimate[1]-sp_vote_voice$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(sp_vote_voice$conf.int[1],3,sp_vote_voice$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of  Voice (Criticism) on Support: SP voters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(sp_vote_exit$estimate[1]-sp_vote_exit$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(sp_vote_exit$conf.int[1],3,sp_vote_exit$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Exit on Support: SP voters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

###Figure 4 (appendix): corruption effects for all three strategies / binary DV for MP voters
par(mfrow=c(3,1))
plot(mp_corrupt_protest$estimate[1]-mp_corrupt_protest$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(mp_corrupt_protest$conf.int[1],3,mp_corrupt_protest$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Protest) on Perception of Corruption: MP voters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(mp_corrupt_voice$estimate[1]-mp_corrupt_voice$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(mp_corrupt_voice$conf.int[1],3,mp_corrupt_voice$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of  Voice (Criticism) on Perception of Corruption: MP voters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(mp_corrupt_exit$estimate[1]-mp_corrupt_exit$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(mp_corrupt_exit$conf.int[1],3,mp_corrupt_exit$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Exit on Perception of Corruption: MP voters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

###Figure 5 (appendix): corruption effects for all three strategies / binary DV for SP voters
par(mfrow=c(3,1))
plot(sp_corrupt_protest$estimate[1]-sp_corrupt_protest$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(sp_corrupt_protest$conf.int[1],3,sp_corrupt_protest$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Protest) on Perception of Corruption: SP voters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(sp_corrupt_voice$estimate[1]-sp_corrupt_voice$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(sp_corrupt_voice$conf.int[1],3,sp_corrupt_voice$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of  Voice (Criticism) on Perception of Corruption: SP voters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(sp_corrupt_exit$estimate[1]-sp_corrupt_exit$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(sp_corrupt_exit$conf.int[1],3,sp_corrupt_exit$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Exit on Perception of Corruption: SP voters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)


#===============================================================Strategies relative to each other===============================================================================================#
###Figures 6 and 7: Vote choice (7 point scale turned into a binary outcome)========================================================================#

####MP#### 
mp_protest.criticism <- t.test(mp[mp$protest_strategy==1,]$support, mp[mp$criticism_strategy==1,]$support)
mp_protest.criticism.effect <- mp_protest.criticism$estimate[1]-mp_protest.criticism$estimate[2]

mp_protest.exit <- t.test(mp[mp$protest_strategy==1,]$support, mp[mp$exit_strategy==1,]$support)
mp_protest.exit.effect <- mp_protest.exit$estimate[1]-mp_protest.exit$estimate[2]

mp_exit.criticism <- t.test(mp[mp$criticism_strategy==1,]$support, mp[mp$exit_strategy==1,]$support)
mp_exit.criticism.effect <- mp_exit.criticism$estimate[1]-mp_exit.criticism$estimate[2]

###Figure 6 (appendix): vote effects for all three strategies / binary support level for MP supporters

par(mfrow=c(3,1))
plot(mp_protest.criticism.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(mp_protest.criticism$conf.int[1],3,mp_protest.criticism$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Criticism on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(mp_protest.exit.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(mp_protest.exit$conf.int[1],3,mp_protest.exit$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Exit on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(mp_exit.criticism.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(mp_exit.criticism$conf.int[1],3,mp_exit.criticism$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Criticism Relative to Exit on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

####SP#### 
sp_protest.criticism <- t.test(sp[sp$protest_strategy==1,]$support, sp[sp$criticism_strategy==1,]$support)
sp_protest.criticism.effect <- sp_protest.criticism$estimate[1]-sp_protest.criticism$estimate[2]

sp_protest.exit <- t.test(sp[sp$protest_strategy==1,]$support, sp[sp$exit_strategy==1,]$support)
sp_protest.exit.effect <- sp_protest.exit$estimate[1]-sp_protest.exit$estimate[2]

sp_exit.criticism <- t.test(sp[sp$criticism_strategy==1,]$support, sp[sp$exit_strategy==1,]$support)
sp_exit.criticism.effect <- sp_exit.criticism$estimate[1]-sp_exit.criticism$estimate[2]

###Figure 7 (appendix): vote effects for all three strategies / binary support level for SP supporters

par(mfrow=c(3,1))
plot(sp_protest.criticism.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(sp_protest.criticism$conf.int[1],3,sp_protest.criticism$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Criticism on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(sp_protest.exit.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(sp_protest.exit$conf.int[1],3,sp_protest.exit$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Exit on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(sp_exit.criticism.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(sp_exit.criticism$conf.int[1],3,sp_exit.criticism$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Criticism Relative to Exit on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

#===============================================================Corruption (7 point scale turned into a binary outcome)====================================================#
###SP v. MP Appendix Figures 8 and 9

###MP###
mp_protest.criticism.corrupt <- t.test(mp[mp$protest_strategy==1,]$corrupt, mp[mp$criticism_strategy==1,]$corrupt)
mp_protest.criticism.corrupt.effect <- mp_protest.criticism.corrupt$estimate[1]-mp_protest.criticism.corrupt$estimate[2]

mp_protest.exit.corrupt <- t.test(mp[mp$protest_strategy==1,]$corrupt, mp[mp$exit_strategy==1,]$corrupt)
mp_protest.exit.corrupt.effect <- mp_protest.exit.corrupt$estimate[1]-mp_protest.exit.corrupt$estimate[2]

mp_exit.criticism.corrupt <- t.test(mp[mp$criticism_strategy==1,]$corrupt, mp[mp$exit_strategy==1,]$corrupt)
mp_exit.criticism.corrupt.effect <- mp_exit.criticism.corrupt$estimate[1]-mp_exit.criticism.corrupt$estimate[2]

###Figure 8 (appendix): corruption effects for all three strategies / binary DV -- MP voters

par(mfrow=c(3,1))
plot(mp_protest.criticism.corrupt.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(mp_protest.criticism.corrupt$conf.int[1],3,mp_protest.criticism.corrupt$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Criticism on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(mp_protest.exit.corrupt.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(mp_protest.exit.corrupt$conf.int[1],3,mp_protest.exit.corrupt$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Exit on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(mp_exit.criticism.corrupt.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(mp_exit.criticism.corrupt$conf.int[1],3,mp_exit.criticism.corrupt$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Criticism Relative to Exit on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

###SP### 
sp_protest.criticism.corrupt <- t.test(sp[sp$protest_strategy==1,]$corrupt, sp[sp$criticism_strategy==1,]$corrupt)
sp_protest.criticism.corrupt.effect <- sp_protest.criticism.corrupt$estimate[1]-sp_protest.criticism.corrupt$estimate[2]

sp_protest.exit.corrupt <- t.test(sp[sp$protest_strategy==1,]$corrupt, sp[sp$exit_strategy==1,]$corrupt)
sp_protest.exit.corrupt.effect <- sp_protest.exit.corrupt$estimate[1]-sp_protest.exit.corrupt$estimate[2]

sp_exit.criticism.corrupt <- t.test(sp[sp$criticism_strategy==1,]$corrupt, sp[sp$exit_strategy==1,]$corrupt)
sp_exit.criticism.corrupt.effect <- sp_exit.criticism.corrupt$estimate[1]-sp_exit.criticism.corrupt$estimate[2]

###Figure 9 (appendix): corruption effects for all three strategies / binary DV -- SP voters

par(mfrow=c(3,1))
plot(sp_protest.criticism.corrupt.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(sp_protest.criticism.corrupt$conf.int[1],3,sp_protest.criticism.corrupt$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Criticism on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(sp_protest.exit.corrupt.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(sp_protest.exit.corrupt$conf.int[1],3,sp_protest.exit.corrupt$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Exit on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(sp_exit.criticism.corrupt.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(sp_exit.criticism.corrupt$conf.int[1],3,sp_exit.criticism.corrupt$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Criticism Relative to Exit on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)


#===============================================================By Respondents' own Protest History==========================================================================

##attended at least one protest
survey$candlelight_protests_attendee <- ifelse(survey$candlelight_protests==4, 0, 1)
mean(survey$candlelight_protests_attendee)
candles <- survey[survey$candlelight_protests_attendee==1,] #subset to protesters
dim(candles) #294
sum(candles$mp) #186 of protesters in MP (about 63%)
sum(candles$sp) #24 in SP

##vote
candles_vote_protest <- t.test(candles[candles$protest_strategy==1,]$support, candles[candles$loyalty_strategy==1,]$support)
candles_vote_exit <- t.test(candles[candles$exit_strategy==1,]$support, candles[candles$loyalty_strategy==1,]$support)
candles_vote_voice <- t.test(candles[candles$criticism_strategy==1,]$support, candles[candles$loyalty_strategy==1,]$support)

##corruption

candles_corrupt_protest <- t.test(candles[candles$protest_strategy==1,]$corrupt, candles[candles$loyalty_strategy==1,]$corrupt)
candles_corrupt_exit <- t.test(candles[candles$exit_strategy==1,]$corrupt, candles[candles$loyalty_strategy==1,]$corrupt)
candles_corrupt_voice <- t.test(candles[candles$criticism_strategy==1,]$corrupt, candles[candles$loyalty_strategy==1,]$corrupt)

###Figure 10 (appendix): effects of strategies on vote among protest attendees / binary DV

par(mfrow=c(3,1))
plot(candles_vote_protest$estimate[1]-candles_vote_protest$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(candles_vote_protest$conf.int[1],3,candles_vote_protest$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Protest) on Support: protesters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(candles_vote_voice$estimate[1]-candles_vote_voice$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(candles_vote_voice$conf.int[1],3,candles_vote_voice$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of  Voice (Criticism) on Support: protesters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(candles_vote_exit$estimate[1]-candles_vote_exit$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(candles_vote_exit$conf.int[1],3,candles_vote_exit$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Exit on Support: protesters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

###Figure 11 (appendix): effects of strategies on perception of corruption among protest attendees / binary DV

par(mfrow=c(3,1))
plot(candles_corrupt_protest$estimate[1]-candles_corrupt_protest$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(candles_corrupt_protest$conf.int[1],3,candles_corrupt_protest$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Protest) on Perception of Corruption: protesters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(candles_corrupt_voice$estimate[1]-candles_corrupt_voice$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(candles_corrupt_voice$conf.int[1],3,candles_corrupt_voice$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of  Voice (Criticism) on Perception of Corruption: protesters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(candles_corrupt_exit$estimate[1]-candles_corrupt_exit$estimate[2],3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(candles_corrupt_exit$conf.int[1],3,candles_corrupt_exit$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Exit on Perception of Corruption: protesters",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

#===============================================================Strategies relative to each other===============================================================================================#

###Figure 12 (appendix) effects of strategies (compared to each other) on vote among protest attendees

candles_protest.criticism <- t.test(candles[candles$protest_strategy==1,]$support, candles[candles$criticism_strategy==1,]$support)
candles_protest.criticism.effect <- candles_protest.criticism$estimate[1]-candles_protest.criticism$estimate[2]

candles_protest.exit <- t.test(candles[candles$protest_strategy==1,]$support, candles[candles$exit_strategy==1,]$support)
candles_protest.exit.effect <- candles_protest.exit$estimate[1]-candles_protest.exit$estimate[2]

candles_exit.criticism <- t.test(candles[candles$criticism_strategy==1,]$support, candles[candles$exit_strategy==1,]$support)
candles_exit.criticism.effect <- candles_exit.criticism$estimate[1]-candles_exit.criticism$estimate[2]

par(mfrow=c(3,1))
plot(candles_protest.criticism.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(candles_protest.criticism$conf.int[1],3,candles_protest.criticism$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Criticism on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(candles_protest.exit.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(candles_protest.exit$conf.int[1],3,candles_protest.exit$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Exit on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(candles_exit.criticism.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(candles_exit.criticism$conf.int[1],3,candles_exit.criticism$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Criticism Relative to Exit on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

###Figure 13 (appendix) effects of strategies (compared to each other) on perceptions of corruption among protest attendees

candles_protest.criticism.corrupt <- t.test(candles[candles$protest_strategy==1,]$corrupt, candles[candles$criticism_strategy==1,]$corrupt)
candles_protest.criticism.corrupt.effect <- candles_protest.criticism.corrupt$estimate[1]-candles_protest.criticism.corrupt$estimate[2]

candles_protest.exit.corrupt <- t.test(candles[candles$protest_strategy==1,]$corrupt, candles[candles$exit_strategy==1,]$corrupt)
candles_protest.exit.corrupt.effect <- candles_protest.exit.corrupt$estimate[1]-candles_protest.exit.corrupt$estimate[2]

candles_exit.criticism.corrupt <- t.test(candles[candles$criticism_strategy==1,]$corrupt, candles[candles$exit_strategy==1,]$corrupt)
candles_exit.criticism.corrupt.effect <- candles_exit.criticism.corrupt$estimate[1]-candles_exit.criticism.corrupt$estimate[2]

par(mfrow=c(3,1))
plot(candles_protest.criticism.corrupt.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(candles_protest.criticism.corrupt$conf.int[1],3,candles_protest.criticism.corrupt$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Criticism on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(candles_protest.exit.corrupt.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(candles_protest.exit.corrupt$conf.int[1],3,candles_protest.exit.corrupt$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Protest Relative to Exit on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

plot(candles_exit.criticism.corrupt.effect,3,cex=3,pch=20,xlim=c(-0.4,0.4),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(candles_exit.criticism.corrupt$conf.int[1],3,candles_exit.criticism.corrupt$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Criticism Relative to Exit on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-0.4,0.4,by=0.1)),labels=c("-40", "-30", "-20", "-10", "0", "10", "20", "30", "40"), cex.axis=1.5)
mtext("Percentage Point Change",side=1,cex=1.8,line=3)

#===============================================================Table 4-6: Evidence of random assignment====================================================#

#baseline means and standard deviations for demographic characteristics and other pre-treatment measures by experimental group.

#subset survey based on strategies 

loyalty_survey <- survey[which(survey$loyalty_strategy==1),] #250
exit_survey <- survey[which(survey$exit_strategy==1),] #251 
criticism_survey <- survey[which(survey$criticism_strategy==1),] #247
protest_survey <- survey[which(survey$protest_strategy==1),] #252

###Table 4 - exit
t.test(loyalty_survey$male, exit_survey$male)
t.test(as.numeric(as.character(loyalty_survey$age)), as.numeric(as.character(exit_survey$age)))
t.test(as.numeric(as.character(loyalty_survey$education)), as.numeric(as.character(exit_survey$education)))
t.test(as.numeric(as.character(loyalty_survey$ideology_1)), as.numeric(as.character(exit_survey$ideology_1)))
t.test(as.numeric(as.character(loyalty_survey$candlelight_protests_attendee)), as.numeric(as.character(exit_survey$candlelight_protests_attendee)))
t.test(loyalty_survey$pp, exit_survey$pp)
t.test(loyalty_survey$mp, exit_survey$mp)
t.test(loyalty_survey$sp,exit_survey$sp)
t.test(loyalty_survey$jp, exit_survey$jp)
t.test(loyalty_survey$other, exit_survey$other)

###Table 5 - criticism
t.test(loyalty_survey$male, criticism_survey$male)
t.test(as.numeric(as.character(loyalty_survey$age)), as.numeric(as.character(criticism_survey$age)))
t.test(as.numeric(as.character(loyalty_survey$education)), as.numeric(as.character(criticism_survey$education)))
t.test(as.numeric(as.character(loyalty_survey$ideology_1)),as.numeric(as.character(criticism_survey$ideology_1)))
t.test(as.numeric(as.character(loyalty_survey$candlelight_protests_attendee)), as.numeric(as.character(criticism_survey$candlelight_protests_attendee)))
t.test(loyalty_survey$pp, criticism_survey$pp)
t.test(loyalty_survey$mp, criticism_survey$mp)
t.test(loyalty_survey$sp, criticism_survey$sp)
t.test(loyalty_survey$jp, criticism_survey$jp)
t.test(loyalty_survey$other, criticism_survey$other)

###Table 6 - protest
t.test(loyalty_survey$male, protest_survey$male)
t.test(as.numeric(as.character(loyalty_survey$education)), as.numeric(as.character(protest_survey$education)))
t.test(as.numeric(as.character(loyalty_survey$age)), as.numeric(as.character(protest_survey$age)))
t.test(as.numeric(as.character(loyalty_survey$ideology_1)),as.numeric(as.character(protest_survey$ideology_1)))
t.test(as.numeric(as.character(loyalty_survey$candlelight_protests_attendee)), as.numeric(as.character(protest_survey$candlelight_protests_attendee)))
t.test(loyalty_survey$pp, protest_survey$pp)
t.test(loyalty_survey$mp, protest_survey$mp)
t.test(loyalty_survey$sp, protest_survey$sp)
t.test(loyalty_survey$jp, protest_survey$jp)
t.test(loyalty_survey$other, protest_survey$other)


#===============================================================Robustness checks====================================================#

#plot vote effects for all three strategies / ordinal DV

#difference in means for vote choice - 7 point scale

diff.in.means4 <- t.test(survey[survey$protest_strategy==1,]$vote, survey[survey$loyalty_strategy==1,]$vote)
effect4 <- diff.in.means4$estimate[1]-diff.in.means4$estimate[2]

diff.in.means5 <- t.test(survey[survey$criticism_strategy==1,]$vote, survey[survey$loyalty_strategy==1,]$vote)
effect5 <- diff.in.means5$estimate[1]-diff.in.means5$estimate[2]

diff.in.means6 <- t.test(survey[survey$exit_strategy==1,]$vote, survey[survey$loyalty_strategy==1,]$vote)
effect6 <- diff.in.means6$estimate[1]-diff.in.means6$estimate[2]


###Figure 14 (appendix): effects of strategies on vote / ordinal DV

par(mfrow=c(3,1))
plot(effect4,3,cex=3,pch=20,xlim=c(-3,3),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(diff.in.means4$conf.int[1],3,diff.in.means4$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Protest) on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-3,3,by=0.5)), cex.axis=1.5)
mtext("Change in Level of Support",side=1,cex=1.8,line=3)

plot(effect5,3,cex=3,pch=20,xlim=c(-3,3),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(diff.in.means5$conf.int[1],3,diff.in.means5$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Criticism) on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-3,3,by=0.5)), cex.axis=1.5)
mtext("Change in Level of Support",side=1,cex=1.8,line=3)

plot(effect6,3,cex=3,pch=20,xlim=c(-3,3),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(diff.in.means6$conf.int[1],3,diff.in.means6$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Exit on Support",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-3,3,by=0.5)), cex.axis=1.5)
mtext("Change in Level of Support",side=1,cex=1.8,line=3)

###plot corruption effects for all three strategies / ordinal DV

corruption_protest2 <- t.test(survey[survey$protest_strategy==1,]$corrupt_scale, survey[survey$loyalty_strategy==1,]$corrupt_scale)
corruption_effect_protest2 <- corruption_protest2$estimate[1]-corruption_protest2$estimate[2]

corruption_voice2 <- t.test(survey[survey$criticism_strategy==1,]$corrupt_scale, survey[survey$loyalty_strategy==1,]$corrupt_scale)
corruption_effect_voice2 <- corruption_voice2$estimate[1]-corruption_voice2$estimate[2]

corruption_exit2 <- t.test(survey[survey$exit_strategy==1,]$corrupt_scale, survey[survey$loyalty_strategy==1,]$corrupt_scale)
corruption_effect_exit2 <- corruption_exit2$estimate[1]-corruption_exit2$estimate[2]

###Figure 15 (appendix): effect on perception of corruption / ordinal DV

par(mfrow=c(3,1))
plot(corruption_effect_protest2,3,cex=3,pch=20,xlim=c(-3,3),yaxt="n",ylab="", xlab="",xaxt="n", ylim=c(0,4))
segments(corruption_protest2$conf.int[1],3,corruption_protest2$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Protest) on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-3,3,by=0.5)), cex.axis=1.5)
mtext("Change in Level of Corruption",side=1,cex=1.8,line=3)

plot(corruption_effect_voice2,3,cex=3,pch=20,xlim=c(-3,3),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(corruption_voice2$conf.int[1],3,corruption_voice2$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Voice (Criticism) on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-3,3,by=0.5)), cex.axis=1.5)
mtext("Change in Level of Corruption",side=1,cex=1.8,line=3)

plot(corruption_effect_exit2,3,cex=3,pch=20,xlim=c(-3,3),yaxt="n",ylab="",ylim=c(0,4),xlab="",xaxt="n")
segments(corruption_exit2$conf.int[1],3,corruption_exit2$conf.int[2],3,lwd=4)
abline(v=0,lty=3)
mtext("Effect of Exit on Perception of Corruption",side=3,cex=2.2,line=1)
axis(1,at=c(seq(-3,3,by=0.5)), cex.axis=1.5)
mtext("Change in Level of Corruption",side=1,cex=1.8,line=3)

##create variables for treatment indicators
survey$loyalty <- ifelse(survey$loyalty_strategy=="1", 1, 0)
survey$exit <- ifelse(survey$exit_strategy=="1", 1, 0)
survey$criticism <- ifelse(survey$criticism_strategy=="1", 1, 0)
survey$protest_condition <- ifelse(survey$protest_strategy=="1", 1, 0)

survey$vote <- as.factor(survey$vote)
survey$corrupt_scale <- as.factor(survey$corrupt_scale)

###Table 7 (appendix): OLS regression, including covariates / binary DV

m5 <- lm(support ~ exit + criticism + protest_condition + male + age + candlelight_protests_attendee + education + partisanship + ideology, data = survey)

m5.1 <- lm(corrupt ~ exit + criticism + protest_condition + male + age + candlelight_protests_attendee + education + partisanship  + ideology, data = survey)

stargazer(m5, m5.1, single.row = TRUE)

###Table 8 (appendix): logit
m3 <- glm(support ~ exit + criticism + protest_condition, family=binomial(link="logit"), data = survey)

m3.1 <- glm(corrupt ~ exit + criticism + protest_condition, family=binomial(link="logit"), data = survey)

stargazer(m3, m3.1, align=TRUE)

###Table 9 (appendix): logit with covariates
m4 <- glm(support ~ exit + criticism + protest_condition + male + age + candlelight_protests_attendee + education + partisanship + ideology, family=binomial(link="logit"), data = survey)
summary(m4)
m4.1 <- glm(corrupt ~ exit + criticism + protest_condition + male + age + candlelight_protests_attendee + education + partisanship + ideology, family=binomial(link="logit"), data = survey)

stargazer(m4, m4.1, align=TRUE, single.row = TRUE)

###Table 10 (appendix): ordered logit 
m1 <- polr(vote ~ exit + criticism + protest_condition, data=survey, Hess=TRUE)
summary(m1)

m1.1 <- polr(corrupt_scale ~ exit + criticism + protest_condition, data=survey, Hess=TRUE)
summary(m1.1)
stargazer(m1, m1.1, align=TRUE)

###Table 11 (appendix): ordered logit with covariates
survey$education <- relevel(survey$education, ref="1")
survey$age <- relevel(survey$age, ref="1")
survey$partisanship <- relevel(survey$partisanship, ref="1")
levels(survey$partisanship)

m2 <- polr(vote ~ exit + criticism + protest_condition + male + age + candlelight_protests_attendee + education + partisanship + ideology, data=survey, Hess=TRUE)
summary(m2)

m2.1 <- polr(corrupt_scale ~ exit + criticism + protest_condition + male + age + candlelight_protests_attendee + education + partisanship + ideology, data=survey, Hess=TRUE)
summary(m2)

stargazer(m2, m2.1, align=TRUE, single.row = TRUE)

####end####
